#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>

int main()
{
	pid_t pid;
	int count=0;
	pid = fork();
	
	if(pid < 0 )
		printf("error in fork \n");
	else if (pid ==0){
		printf("I'm the childA process,ID = %d  \n",getpid());
                printf("I'm A the parent process,ID = %d  \n",getppid());
		while(1){
			count++;
			printf("count = %d\n",count);
			sleep(2);
		}
	}else{
	        printf("I'm the childB process,ID = %d  \n",getpid());
                printf("I'm B the parent process,ID = %d  \n",getppid());
	        while(1){
                        count++;
                        printf("count = %d\n",count);
                        sleep(2);
                }
	}
	return 0;
}
